using System;
using System.Data;

 

/// <summary>
/// Summary description for Recruiter
/// </summary>
public partial class RecruitVietnam
{
    #region Add Folder
    public bool SaveFolder(
    string recruiterID, string folderName,
    string folderDescription, string folderManager)
    {
        bool save = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
                    = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPSaveFolder";
            sqlServerProvider.CommandType = 
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[4] { "@RecruiterID", 
            "@FolderName", "@FolderDescription", 
            "@FolderManager"};
            sqlServerProvider.ValueCollection =
            new string[4] { recruiterID, folderName, folderDescription, folderManager };
            save = (sqlServerProvider.ExecuteNonQuery() > 0);
            sqlServerProvider.CloseConnection();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
    #endregion

    #region Delete Applied Resume by Job Seeker
    public bool DeleteAppliedResume(
    string recruiterID, string jobID, 
    string resumeID)
    {
        bool deleteItem = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
                    = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPDeleteAppliedResume";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[3] { "@RecruiterID", "@ResumeID", "@JobID" };
            sqlServerProvider.ValueCollection =
            new string[3] { recruiterID, resumeID, jobID };
            deleteItem = (sqlServerProvider.ExecuteNonQuery()>0);
            sqlServerProvider.CloseConnection();                       
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return deleteItem;
    }
    #endregion

    #region Upload Logo
    public bool UploadLogo(
    string recruiterID)
    {
        bool upload = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
                    = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "Update tblRCAccounts Set Logo = 1 where RecruiterID = @RecruiterID";
             
            sqlServerProvider.ParameterCollection =
            new string[1] { "@RecruiterID" };
            sqlServerProvider.ValueCollection =
            new string[1] { recruiterID};
            upload = (sqlServerProvider.ExecuteNonQuery() > 0);
            sqlServerProvider.CloseConnection();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return upload;
    }
    #endregion


    #region Change Status Of Resume for Job Seeker
    public bool ChangeStatusOfResume(
    string recruiterID, string jobID, 
    string resumeID, string status)
    {
        bool changeItem = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
                        = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPChangeAppliedResume";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[4] { "@RecruiterID", "@ResumeID", "@JobID", "@Status" };
            sqlServerProvider.ValueCollection =
            new string[4] { recruiterID, resumeID, jobID, status };
            changeItem = (sqlServerProvider.ExecuteNonQuery() > 0);
            sqlServerProvider.CloseConnection(); 
        }        
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return changeItem;
    }
    #endregion

    #region Add New and Update RC Account
    public int AddNewRCAccount(
      string email,
      string passWord,
      string companyName,
      string englishName,
      string accountType,
       string newsletter,
      string promotion, 
      string resumeAlert
      )
    {
        errorMessage = "";
        int userID = -1;
        try
        {
            SqlServerProvider sqlServerProvider
                        = new SqlServerProvider(connectionString);
            SecurityProvider securityProvider =
            new SecurityProvider();
            sqlServerProvider.CommandText = "SPRCAccount";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[9] { "@UserID", "@Email", 
            "@Password", "@CompanyName", 
            "@EnglishName", "@AccountType",
            "@Newsletter", "@ResumeAlert", 
            "@Promotion" };
            sqlServerProvider.ValueCollection =
            new string[9] { "0", email, 
            securityProvider.RCVEncPwd(passWord), 
            companyName, englishName, accountType, 
            newsletter, resumeAlert, promotion };
            sqlServerProvider.ReturnValueParameter = "@ReturnValue";
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.CloseConnection();
            userID = sqlServerProvider.ReturnValue; 
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return userID;
    }
     
    public bool UpdateRCAccount(string userID,
            string email,
           string companyName,
           string englishName,
           string accountType,
            string newsletter,
           string promotion,
           string resumeAlert)
    {
        errorMessage = "";
        bool update = false;
        try
        {
            SqlServerProvider sqlServerProvider
            = new SqlServerProvider(connectionString);
            SecurityProvider securityProvider =
            new SecurityProvider();
            sqlServerProvider.CommandText = "SPRCAccount";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[9] { "@UserID", "@Email", 
            "@Password", "@CompanyName", 
            "@EnglishName", "@AccountType",
            "@Newsletter", "@ResumeAlert", 
            "@Promotion"};
            sqlServerProvider.ValueCollection =
            new string[9] { userID, email, "", 
            companyName, englishName, accountType, 
            newsletter, resumeAlert, promotion};            
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.CloseConnection();            
            update = true;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return update;
    }

    #endregion

    #region Update Company Information
    public bool UpdateCompany(
        string userID,
        string contact,
        string address,
         string city,
        string tel,
        string fax,
        string country,
        string province,
        string opendate
        )
    {
        errorMessage = "";
        bool update = false;
        try
        {
            SqlServerProvider sqlServerProvider
                        = new SqlServerProvider(connectionString);
             
            sqlServerProvider.CommandText = "SPRCCompany";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[9] { "@RecruiterID", "@Contact", 
            "@Address", "@ProvinceID", 
            "@City", "@OpenDate",
            "@Tel", "@Fax", "@Country"};
            sqlServerProvider.ValueCollection =
            new string[9] { userID, contact, address, 
            province, city, opendate, 
            tel, fax, country};
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.CloseConnection();                                     
            update = true;          
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return update;
    }
    #endregion

    #region Increase Job View by Job Seeker

    #endregion
    
    #region Increase Job View by Job Seeker

    #endregion

    #region ExecuteSQL
    public bool ExecuteSQL(
    string executeQuery)
    {
        bool execute = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
            = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText = executeQuery;
            execute = (sqlServerProvider.ExecuteNonQuery() > 0);
            sqlServerProvider.CloseConnection();                       
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return execute;
    }
    #endregion
    
}